﻿<script type="text/javascript">  
	$(document).ready(function(){  
		$("#tableuser").flexigrid
		(
		{
			url:'http://shoppingcartcnpm.orgfree.com/index.php/Longadmin/user/list',
			dataType: 'json',
			colModel : [
				{display: 'User ID', name : 'u_id', width : 40, sortable : true, align: 'center'},
				{display: 'Họ tên', name : 'u_hoten', width :120, sortable : true, align: 'center'},
				{display: 'Email', name : 'u_email', width :120, sortable : true, align: 'center'},
				{display: 'Điện Thoại', name : 'u_dienthoai', width : 120, sortable : true, align: 'center'},
				{display: 'Đơn Hàng', name : 'orders', width : 120, sortable : true, align: 'center'},
				{display: 'Vai Trò', name : 'u_role', width : 100, sortable : true, align: 'center'}	
				],

			buttons : [
				{name: 'Update', bclass: 'Update',onpress : test},
				{name: 'Delete', bclass: 'delete',onpress : test},
				{separator: true}
				],
			searchitems  : [
				{display: 'UID', name : 'u_id'},
				{display: 'UserName', name : 'u_hoten', isdefault: true}
				],
			title:'Người Dùng',
			usepager: true,
			userRp:true,
			singleSelect: true,
			rp:8,
			showTableToggleBtn: true,
			width:700,
			height:200
			
		}
		);
			
		function test(com,grid) 
			{
				if (com=='Delete')
					{
						
					}
				else if (com=='Update')
					{
						$('.trSelected', grid).each(function() {
							var id = $(this).attr('id');
							id = id.substring(id.lastIndexOf('row')+3);
							alert("Edit row " + id);
							$.nyroModalManual({
								url: 'http://shoppingcartcnpm.orgfree.com/index.php/Longadmin/user/update?id='+id,
								width: 500, // default Width If null, will be calculate automatically
								height: 500, // default Height If null, will be calculate automatically
								minWidth: null, // Minimum width
								minHeight: null, // Minimum height
							});	
						});

					}			
			}
			

	});	
</script>
<table id = "tableuser" style="display:none">
</table>	